package org.shan.lf.sever.controller;

import com.mlnx.common.entity.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.shan.lf.pojo.form.DoctorRegisterForm;
import org.shan.lf.pojo.form.DoctorUpdateForm;
import org.shan.lf.pojo.form.LoginForm;
import org.shan.lf.service.UserService;
import org.shan.spring.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;

/**
 * Created by amanda.shan on 2019-07-28.
 */
@Api(value = "医生用户接口", tags={"医生用户接口"})
@RestController
@RequestMapping("/doctor")
public class DoctorController extends BaseController {

    @Autowired
    private UserService userService;


    @ApiOperation(value="用户登入", notes="")
    @PostMapping("/login")
    public Response login(LoginForm loginForm, HttpServletRequest request,
                          HttpServletResponse response) throws ServletException, IOException {

        return result();
    }

    @ApiOperation(value="注册用户", notes="")
    @PostMapping("")
    public Response register(@Valid DoctorRegisterForm registerForm)  {

        userService.addDoctorAccount(registerForm);
        return result();
    }

    @ApiOperation(value="更新自身信息", notes="")
    @PutMapping("")
    public Response modify(@Valid DoctorUpdateForm updateForm)  {

        userService.modifyDoctor(updateForm);
        return result();
    }
}
